]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Replace "long-press" of click action with ClutterLongPressGesture
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 17 Mar 2022 16:08:33 +0000 (17:08 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 28 Aug 2025 17:14:06 +0000 (19:14 +0200)
Nothing fancy here, just a straightforward replacement of one API with
another.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2853>

js/ui/backgroundMenu.js

index 4b812b250a74e1e157a659a13b5b3e6a008894e5..c88d1efc1dfcd970356d1f3db87f94ac6f5bf61e 100644 (file)
@@ -37,20 +37,21 @@ export function addBackgroundMenu(actor, layoutManager) {
         actor._backgroundMenu.open(BoxPointer.PopupAnimation.FULL);
     }
 
-    let clickAction = new Clutter.ClickAction();
-    clickAction.connect('long-press', (action, theActor, state) => {
-        if (state === Clutter.LongPressState.QUERY) {
-            return (action.get_button() === 0 ||
-                     action.get_button() === 1) &&
-                    !actor._backgroundMenu.isOpen;
-        }
-        if (state === Clutter.LongPressState.ACTIVATE) {
-            let [x, y] = action.get_coords();
-            openMenu(x, y);
-            actor._backgroundManager.ignoreRelease();
-        }
-        return true;
+    const longPressGesture = new Clutter.LongPressGesture({
+        required_button: Clutter.BUTTON_PRIMARY,
     });
+    longPressGesture.connect('recognize', () => {
+        if (actor._backgroundMenu.isOpen)
+            return;
+
+        const coords = longPressGesture.get_coords();
+        const point = new Graphene.Point3D({x: coords.x, y: coords.y});
+        const transformedPoint = actor.apply_transform_to_point(point);
+        openMenu(transformedPoint.x, transformedPoint.y);
+    });
+    actor.add_action(longPressGesture);
+
+    const clickAction = new Clutter.ClickAction();
     clickAction.connect('clicked', action => {
         if (action.get_button() === 3) {
             let [x, y] = action.get_coords();